$(function() {
    //初始化fullpage组件
    $(".container").fullpage({
        //配置参数
        sectionsColor: ["#fadd67", "#84a2d4", "#ef674d", "#ffeedd", "#d04759", "#84d9ed", "#8ac060"], //配置屏幕的颜色
        verticalCentered: false, //设置屏幕内容的对其方式，默认垂直居中，改成顶部对其
        navigation: true, //显示全屏滚动的导航，点容器
        afterLoad:function (link,index) {
            /*index 序号 1开始  当前屏的序号*/
            $('.section').eq(index-1).addClass('now');
        },
        afterRender:function() {
            $('.more').on('click', function(){
                $.fn.fullpage.moveSectionDown(); 
            });
            //监听动画或过度效果结束
            $('.screen03 .cart').on('transitionend', function(){
                $('.screen03 .text').addClass('show');
                $('.screen03 .address').addClass('show');
                $('.screen03 .address').show().find('img:last').fadeIn(1000);
            });

            //随着鼠标拖动，手也跟着移动
            $('.screen07').on('mousemove',function (e) {
                /*鼠标的坐标设置给手*/
                $(this).find('.hand').css({
                    left:e.clientX -190,
                    top:e.clientY - 20
                });
            });
            //点击再来一次，重新播放动画
            $('.screen07 .again').on('click',function () {
                $('.now,.leaved,.show').removeClass('now').removeClass('leaved').removeClass('show'); //清除动态添加的类
                $('content[style]').removeAttr('style'); //删除添加的样式
                $.fn.fullpage.moveTo(1);
             });
        },
        onLeave: function(index, nextIndex, driection){
            if(index == 2 && nextIndex == 3) {
                $('.section').eq(index-1).addClass('leaved');
            }else if(index == 3 && nextIndex ==4) {
                $('.section').eq(index-1).addClass('leaved');
            }else if(index == 5 && nextIndex ==6) {
                $('.section').eq(index-1).addClass('leaved');
                $('.screen05 .box').addClass('show');
            }else if (index == 6 && nextIndex == 7){
                $('.screen06 .star').addClass('show');
                $('.screen06 .text').addClass('show');
                $('.screen06 .star img').each(function(i,item){
                   $(this).css('transition-delay',i*0.5 + 's');
                });
            }
        },
        scrollingSpeed: 1000,
    });
});